package com.kitty.game.player;

import com.kitty.game.role.model.Role;
import com.kitty.common.utils.SpringUtils;
import com.kitty.game.player.model.PlayerProfile;

import java.util.Map;

/**
 * 玩家表字段数据迁移
 */
public class DataTransmitUtil {

    public static void transmitPlayer(Role role) {
//        role.getGuardBox().setGuards(role.getGuards());
//        role.getFriendBox().setFriends(role.getFriends());
      //  LoggerUtils.error("数据迁移玩家[{}]=[{}]", role.getUid(), role.getName());
        role.save();
    }

    public static void beginTransmit() {
        try {
            for (Map.Entry<Long, PlayerProfile> entry : SpringUtils.getPlayerService().getAllPlayerProfiles().entrySet()) {
                long playerId = entry.getKey();
                Role role = SpringUtils.getPlayerService().getPlayerBy(playerId);
                transmitPlayer(role);
                Thread.sleep(100);
            }
        } catch (Exception e) {
        //    LoggerUtils.error("", e);
        }

    }
}
